Page({
    data: {
        tempFilePaths: "",
        imgheight: 0,
        img: [],
        page_loading: !0,
        iphone_x: !1
    },
    add: function() {
        var t = this, e = 6 - t.data.img.length;
        wx.chooseImage({
            count: e,
            sizeType: [ "original", "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(e) {
                var a = e.tempFilePaths, i = t.data.img;
                a.forEach(function(e, o) {
                    wx.showLoading({
                        type: "loading",
                        duration: 0
                    }), wx.uploadFile({
                        url: getApp().api.default.upload_image,
                        filePath: e,
                        name: "image",
                        success: function(e) {
                            var n = JSON.parse(e.data), s = {
                                pic_url: n.data.url,
                                id: n.data.id
                            };
                            0 == n.code && i.push(s), t.setData({
                                img: i
                            }), wx.setStorage({
                                key: "goods_detail",
                                data: i
                            }), o == a.length - 1 && wx.hideLoading();
                        }
                    });
                });
            }
        });
    },
    imageLoad: function(t) {
        var e = t.currentTarget.dataset.index, a = t.detail.width, i = t.detail.height;
        console.log(t, a, i);
        var o = this.data.img;
        o[e].height = i * (702 / a), this.setData({
            img: o
        });
    },
    clear: function(t) {
        var e = t.currentTarget.dataset.index, a = this.data.img;
        a.splice(e, 1), this.setData({
            img: a
        }), wx.setStorage({
            key: "goods_detail",
            data: a
        });
    },
    onLoad: function(t) {
        var e = this;
        var a = wx.getSystemInfoSync();
        if (a.model) {
          a.model.indexOf("iphone_x") > -1 && this.setData({
            iphone_x: !0
          })
        }
       wx.getStorage({
            key: "goods_detail",
            success: function(t) {
                console.log(t), e.setData({
                    tempFilePaths: t.data
                });
            }
        });
    },
    onReady: function(t) {
        this.setData({
            page_loading: !1
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});